/*************************************************************************
 *
 *  Copyright (C) 2013 Florian Dang <florian.coin@gmail.com>
 *
 *  This file is part of NatusVerse.
 *
 *  NatusVerse is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  NatusVerse is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NatusVerse.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************/

#ifndef INC_RAYTRACER_OBJECTS_LIGHT_H_
#define INC_RAYTRACER_OBJECTS_LIGHT_H_

/*!
 * \file        light.h
 * \brief       Light
 * \author      Florian Dang
 * \date        2013
 */

#include "raytracer/objects/point.h"
#include "graphics/color.h"

namespace raytracer
{
//! Light class
/*!
  Light source
*/
class Light
{
	public:
		typedef color::Color Color;
		typedef struct sLuminance
		{
			float r;
			float g;
			float b;
		} Luminance;

		//! constructors
		Light() {}
		Light(Point source0, Luminance luminance0)
			: source_(source0), luminance_(luminance0) {}
		Light(Point source0, float r0, float g0, float b0)
			: source_(source0)
		{
			set_luminance(r0, b0, g0);
		}

		//! destructors
		~Light() {}

		//! accessors
		inline Point  source() const { return source_; }
		inline Luminance luminance() const { return luminance_; }

		inline void set_source(Point source0) { source_ = source0; }
		inline void set_luminance(Luminance lum0) { luminance_ = lum0; }
		inline void set_luminance(float r0, float g0, float b0) 
		{ 
			luminance_.r = r0;
			luminance_.g = g0;
			luminance_.b = b0;
		}

		inline float intensity_r() const {return luminance().r; }
		inline float intensity_g() const {return luminance().g; }
		inline float intensity_b() const {return luminance().b; }

		void MoveX(float begin, float end, float& sign);

		void Print() const;
		void PrintLuminance() const;

	private:
		Point      source_;     /*!< source, origine of the Light */
		Luminance  luminance_;  /*!< light color luminance */
};
}


#endif  // INC_RAYTRACER_OBJECTS_LIGHT_H_
